<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<meta name="renderer" content="webkit">
		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
		<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
		<link rel="stylesheet" href="../../../layuiadmin/layui/css/layui.css" media="all">
		<link rel="stylesheet" href="../../../layuiadmin/style/admin.css" media="all">
		<link rel="stylesheet" href="../../../css/common.css" media="all">

	</head>
	<body>

		<div class="layui-fluid">
			<div class="layui-row" id="view">
				<form class="layui-form test_edit" lay-filter="test_detail">
					<div class="layui-card">
						<div class="layui-card-body">
							<div class="layui-form-item">
								<label class="layui-form-label">样本编号</label>
								<div class="layui-input-block">
									<input type="text" name="sample_id" autocomplete="off" placeholder="请输入样本编号" class="layui-input">
								</div>
							</div>
							<div class="layui-form-item">
								<label class="layui-form-label">采集医院</label>
								<div class="layui-input-block">
									<input type="text" name="hospital" placeholder="请输入采集医院" autocomplete="off" class="layui-input">
								</div>
							</div>

							<div class="layui-form-item">
								<div class="layui-inline">
									<label class="layui-form-label">采集时间</label>
									<div class="layui-input-inline">
										<input type="text" name="sample_time" id="sample_time" placeholder="请选择采集时间" autocomplete="off" class="layui-input">
									</div>
								</div>
								<div class="layui-inline">
									<label class="layui-form-label">检测类型</label>
									<div class="layui-input-inline">
										<select name="test_type" lay-filter="test_type" class="test_type">
											<!-- <option value="-1">请选择</option> -->
										</select>
									</div>
								</div>
							</div>

						</div>
					</div>

					<div class="layui-card">
						<div class="layui-card-body">

							<div class="layui-form-item">
								<div class="layui-inline">
									<label class="layui-form-label">孕妇姓名</label>
									<div class="layui-input-inline">
										<input type="text" name="name" placeholder="请输入孕妇姓名" autocomplete="off" class="layui-input">
									</div>
								</div>
								<div class="layui-inline">
									<label class="layui-form-label">出生日期</label>
									<div class="layui-input-inline">
										<input type="text" name="birthday" id="birthday" placeholder="请选择出生日期" autocomplete="off" class="layui-input">
									</div>
								</div>
							</div>

							<div class="layui-form-item">
								<div class="layui-inline">
									<label class="layui-form-label">身高（cm）</label>
									<div class="layui-input-inline">
										<input type="text" name="height" placeholder="请输入身高（cm）" autocomplete="off" class="layui-input">
									</div>
								</div>
								<div class="layui-inline">
									<label class="layui-form-label">体重（kg）</label>
									<div class="layui-input-inline">
										<input type="text" name="weight" placeholder="请输入体重（kg）" autocomplete="off" class="layui-input">
									</div>
								</div>
							</div>
							<div class="layui-form-item">
								<div class="layui-inline">
									<label class="layui-form-label">身份证号</label>
									<div class="layui-input-inline">
										<input type="text" name="idcard" placeholder="请输入孕妇身份证号" autocomplete="off" class="layui-input">
									</div>
								</div>
								<div class="layui-inline">
									<label class="layui-form-label">电话号码</label>
									<div class="layui-input-inline">
										<input type="text" name="mobile" placeholder="请输入孕妇电话号码" autocomplete="off" class="layui-input">
									</div>
								</div>
							</div>
							<div class="layui-form-item">
								<label class="layui-form-label">末次月经</label>
								<div class="layui-input-block">
									<input type="text" name="last_menstruation" id="last_menstruation" placeholder="请选择末次月经" autocomplete="off"
									 class="layui-input">
								</div>
							</div>
							<div class="layui-form-item">
								<div class="layui-inline">
									<label class="layui-form-label">孕次</label>
									<div class="layui-input-inline" style="width: 140px;">
										<input type="text" name="pregnant_no" placeholder="请输入孕次" lay-verify="number" autocomplete="off" class="layui-input">
									</div>
									<div class="layui-form-mid layui-word-aux">（怀孕次数）</div>
								</div>
								<div class="layui-inline">
									<label class="layui-form-label">产次</label>
									<div class="layui-input-inline" style="width: 140px;">
										<input type="text" name="pregnant_no" placeholder="请输入临产次数" lay-verify="number" autocomplete="off" class="layui-input">
									</div>
									<div class="layui-form-mid layui-word-aux">（临产次数）</div>
								</div>
							</div>

							<div class="layui-form-item">
								<div class="layui-inline">
									<label class="layui-form-label">孕周</label>
									<div class="layui-input-inline" style="width: 100px;">
										<input type="text" name="pregnant_week" lay-verify="number" placeholder="请输入周" autocomplete="off" class="layui-input">
									</div>
									<div class="layui-form-mid">周</div>
									<div class="layui-input-inline" style="width: 100px;">
										<input type="text" name="pregnant_day" lay-verify="number" value="0" placeholder="请输入天" autocomplete="off"
										 class="layui-input">
									</div>
									<div class="layui-form-mid">天</div>
								</div>
							</div>
						</div>
					</div>

					<div class="layui-card">
						<div class="layui-card-body">
							<div class="layui-form-item">
								<label class="layui-form-label">本次妊娠情况</label>
								<div class="layui-input-block gestation_info"></div>
							</div>

							<div class="layui-form-item">
								<label class="layui-form-label">孕妇既往史</label>
								<div class="layui-form-mid layui-word-aux">【多选题】</div>
								<div class="layui-input-block pregnant_history">
									<!-- <input type="checkbox" name="pregnant_history[write]" lay-skin="primary" title="写作" checked="">
								<input type="checkbox" name="pregnant_history[read]" lay-skin="primary" title="阅读">
								<input type="checkbox" name="pregnant_history[game]" lay-skin="primary" title="游戏" disabled=""> -->
								</div>
							</div>
							<div style="padding: 9px 60px;">
								不良孕产史 <span class="layui-word-aux">(若有，请填写
									<text class="text_red_color">自然流</text>
									产次数；
									<text class="text_red_color">死胎</text>
									次数；
									<text class="text_red_color">新生儿死亡</text>
									次数；
									<text class="text_red_color">畸形儿</text>
									史次数)</span>
							</div>
							<div class="layui-form-item">
								<div class="layui-input-inline" style="margin-left: 145px">
									<select name="pregnant_bad_select" lay-filter="pregnant_bad">
										<option value="无">无</option>
										<option value="有">有</option>
									</select>
								</div>
								<div class="layui-form-item padding_top10 layui-hide pregnant_bad_input">
									<label class="layui-form-label"></label>
									<div class="layui-input-block">
										<input type="text" name="pregnant_bad" placeholder="请输入不良孕产史" autocomplete="off" class="layui-input">
									</div>
								</div>
							</div>
							<div class="layui-form-item">
								<label class="layui-form-label">B超</label>
								<div class="layui-input-block b_mode">
									<!-- <input type="radio" name="b_mode" value="男" title="男" checked="">
								<input type="radio" name="b_mode" value="女" title="女">
								<input type="radio" name="b_mode" value="禁" title="禁用" disabled=""> -->
								</div>
							</div>
							<div class="layui-form-item">
								<label class="layui-form-label">筛查模式</label>
								<div class="layui-form-mid layui-word-aux">【多选题】</div>
								<div class="layui-input-block screening">
									<!-- <input type="checkbox" name="screening[write]" lay-skin="primary" title="写作" checked="">
								<input type="checkbox" name="screening[read]" lay-skin="primary" title="阅读">
								<input type="checkbox" name="screening[game]" lay-skin="primary" title="游戏" disabled=""> -->
								</div>
							</div>
							<div class="layui-form-item">
								<div class="layui-inline">
									<label class="layui-form-label">超声NT测定孕周</label>
									<div class="layui-input-inline" style="width: 100px;">
										<input type="text" name="ultrasound_week" value="0" lay-verify="number" placeholder="请输入周" autocomplete="off"
										 class="layui-input">
									</div>
									<div class="layui-form-mid">周</div>
									<div class="layui-input-inline" style="width: 100px;">
										<input type="text" name="ultrasound_day" value="0" lay-verify="number" placeholder="请输入天" autocomplete="off"
										 class="layui-input">
									</div>
									<div class="layui-form-mid">天</div>
								</div>
								<div class="layui-inline">
									<label class="layui-form-label">超声NT测定值</label>
									<div class="layui-input-inline">
										<input type="text" name="ultrasound_value" value="0" lay-verify="number" placeholder="请输入周" autocomplete="off"
										 class="layui-input">
									</div>
									<div class="layui-form-mid">mm</div>
								</div>
							</div>
							<div class="layui-form-item">
								<label class="layui-form-label">母体血清筛查风险</label>
								<div class="layui-input-block serum"></div>
									
								<div class="layui-form-item padding_top10 serum_input layui-hide">
									<div class="layui-input-block">21三体综合征值</div>
									<div class="layui-input-block">
										<input type="text" name="serum_21" placeholder="请输入21三体综合征值" autocomplete="off" class="layui-input">
									</div>
								</div>
								<div class="layui-form-item serum_input layui-hide">
									<label class="layui-input-block">18三体综合征值</label>
									<div class="layui-input-block">
										<input type="text" name="serum_18" placeholder="请输入18三体综合征值" autocomplete="off" class="layui-input">
									</div>
								</div>
								<div class="layui-form-item serum_input layui-hide">
									<label class="layui-input-block">13三体综合征值</label>
									<div class="layui-input-block">
										<input type="text" name="serum_13" placeholder="请输入13三体综合征值" autocomplete="off" class="layui-input">
									</div>
								</div>
							</div>
							<div class="" style="padding: 9px 15px;">夫妻双方染色体检查结果：</div>
							<div class="layui-form-item">
								<label class="layui-form-label">孕妇染色体核型</label>
								<div class="layui-input-inline">
									<select name="chromosome_gravida_select" lay-filter="chromosome_gravida">
										<option value="未做">未做</option>
										<option value="正常">正常</option>
										<option value="异常">异常</option>
									</select>
								</div>
								<div class="layui-form-item padding_top10 layui-hide chromosome_gravida_input">
									<div class="layui-input-block">
										<input type="text" name="chromosome_gravida" placeholder="请输入孕妇染色体核型" autocomplete="off" class="layui-input">
									</div>
								</div>
							</div>
							<div class="layui-form-item">
								<label class="layui-form-label">丈夫染色体核型</label>
								<div class="layui-input-inline">
									<select name="chromosome_husband_select" lay-filter="chromosome_husband">
										<option value="未做">未做</option>
										<option value="正常">正常</option>
										<option value="异常">异常</option>
									</select>
								</div>
								<div class="layui-form-item padding_top10 layui-hide chromosome_husband_input">
									<div class="layui-input-block">
										<input type="text" name="chromosome_husband" placeholder="请输入丈夫染色体核型" autocomplete="off" class="layui-input">
									</div>
								</div>
							</div>
						</div>
					</div>
					<div class="layui-form-item text-center">
						<button type="reset" class="layui-btn layui-btn-primary">重置</button>
						<button class="layui-btn" lay-submit="" lay-filter="demo1">立即提交</button>
					</div>
				</form>
			</div>
		</div>
		<script src="../../../layuiadmin/layui/layui.js"></script>
		<script src="../../../js/jquery.min.js"></script>
		<script src="../../../js/jquery.jqprint-0.3.js"></script>
		<script src="../../../js/common.js"></script>
		<script>
			var _data = {
				orderid: getParam('orderid')
			}
			var _data1 = {
				orderid: getParam('orderid')
			}
			// console.log(_data.id);

			layui.config({
				base: '../../../layuiadmin/' //静态资源所在路径
			}).extend({
				index: 'lib/index' //主入口模块
			}).use(['index', 'form', 'laytpl', 'laydate'], function() {
				var $ = layui.$,
					admin = layui.admin,
					laytpl = layui.laytpl,
					laydate = layui.laydate,
					form = layui.form;

				test_type_show();
				gestation_info_show();
				b_mode_show();
				pregnant_history_show();
				screening_show();
				serum_show();
				initdata();


				//出生日期
				laydate.render({
					elem: '#birthday',
					max: formatDate()
				});
				//末次月经
				laydate.render({
					elem: '#last_menstruation',
					max: formatDate()
				});

				form.on('select(pregnant_bad)', function(data) {
					if (data.value == '有') {
						$('.pregnant_bad_input').removeClass('layui-hide');
					} else {
						_data1.pregnant_bad = data.value;
						$('.pregnant_bad_input').addClass('layui-hide');
					}
				});
				form.on('select(chromosome_gravida)', function(data) {
					if (data.value == '异常') {
						$('.chromosome_gravida_input').removeClass('layui-hide');
					} else {
						$('.chromosome_gravida_input').addClass('layui-hide');
					}
				});
				form.on('select(chromosome_husband)', function(data) {
					if (data.value == '异常') {
						$('.chromosome_husband_input').removeClass('layui-hide');
					} else {
						$('.chromosome_husband_input').addClass('layui-hide');
					}
				});
				
				var pregnant_history_arr = [];
				form.on('checkbox(pregnant_history)', function(data) {
					pregnant_history_arr.push(data.value)
					_data1.pregnant_history = pregnant_history_arr.join(',');
				});
				var screening_arr = [];
				form.on('checkbox(screening)', function(data) {
					screening_arr.push(data.value)
					_data1.screening = screening_arr.join(',');
				});
				
				form.on('radio(serum)', function(data) {
					if (data.value == 4 || data.value == -1) {
						$('.serum_input').addClass('layui-hide');
					} else {
						$('.serum_input').removeClass('layui-hide');
					}
				});
				
				//监听提交
				form.on('submit(demo1)', function(data) {
					var data = data.field;
					_data1 = Object.assign(_data1,data);
					if (!data.pregnant_bad) {
						_data1.pregnant_bad = data.pregnant_bad_select
					}
					if (data.chromosome_husband_select != '异常' || !data.chromosome_husband) {
						_data1.chromosome_husband = data.chromosome_husband_select
					}
					if (data.chromosome_gravida_select != '异常' || !data.chromosome_gravida) {
						_data1.chromosome_gravida = data.chromosome_gravida_select
					}
					
					console.log(_data1);
					layer.confirm('确定要修改检测申请单？', function() {
						loading();
						submitdata();
					}, function() {
						layer.msg('取消操作');
					});
					return false;
				});

				function submitdata() {
					$.post(server.updateorders, _data1, function(res, status) {
						if (status == 'success') {
							if (res.code == 0) {
								layer.alert('操作成功', function() {
									parent.layer.closeAll();
									parent.layui.table.reload('test-table-operate');
								});
							} else {
								layer.msg(res.msg);
							}
						} else {
							layer.msg('服务器连接错误');
						}
					});
				}

				function initdata() {
					$.get(server.querytestdetail, _data, function(res, status) {
						if (status == 'success') {
							if (res.code == 0) {
								var data = res.orders_test
								
								if(data.data.pregnant_history){
									if(data.data.pregnant_history.indexOf(',')){
										var pregnant_history1 = data.data.pregnant_history.split(',');
										for (var i = 0; i < pregnant_history1.length; i++) {
											$(".pregnant_history input[value="+ pregnant_history1[i] +"]").attr("checked", true)
										}
									}
								}
								if(data.data.screening){
									if(data.data.screening.indexOf(',')){
										var screening1 = data.data.screening.split(',');
										for (var i = 0; i < screening1.length; i++) {
											$(".screening input[value="+ screening1[i] +"]").attr("checked", true)
										}
									}
								}
								if(data.data.gestation_info){
									$("input[name=gestation_info][value="+ data.data.gestation_info +"]").attr("checked", true)
								}
								if(data.data.serum){
									$("input[name=serum][value="+ data.data.serum +"]").attr("checked", true)
								}
								
								$("select[name=chromosome_gravida_select]").val(data.data.chromosome_gravida);
								$("select[name=chromosome_husband_select]").val(data.data.chromosome_husband);
								if(data.data.chromosome_gravida == '异常'){
									data.data.chromosome_gravida = ''
									$('.chromosome_gravida_input').removeClass('layui-hide');
								} else {
									$('.chromosome_gravida_input').addClass('layui-hide');
								}
								if(data.data.chromosome_husband == '异常'){
									$('.chromosome_husband_input').removeClass('layui-hide');
									data.data.chromosome_husband = ''
								} else {
									$('.chromosome_husband_input').addClass('layui-hide');
								}
								form.val("test_detail", data.data);
								form.render();
							} else {
								layer.msg(res.msg);
							}
						} else {
							layer.msg('服务器连接错误');
						}
					});
				}
			});
		</script>
	</body>
</html>
